package com.fzg.controller;


import com.fzg.common.enums.ResponseWrapper;
import com.fzg.common.model.param.chat.EditChatNickName;
import com.fzg.common.model.param.chat.SendMessageParam;
import com.fzg.service.ChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author fzg
 * @since 2022-07-12
 */
@RestController
@RequestMapping("/chat")
public class ChatController {

    @Autowired
    private ChatService chatService;

    /**
     * 根据对方用户的aid查询当前登陆的用户和对方用户的聊天信息
     * @param userAid 用户aid
     * @return ResponseWrapper
     */
    @GetMapping("/queryChatRecordInfo")
    public ResponseWrapper queryChatRecordInfo(HttpServletRequest request, @RequestParam Integer userAid){
        return chatService.queryChatRecordInfo(request,userAid);
    }

    /**
     * 通过用户aid修改聊天记录页面里面的对方用户昵称
     * @param param 参数
     * @return ResponseWrapper
     */
    @PostMapping("/editChatUserNickName")
    public ResponseWrapper editChatUserNickName(HttpServletRequest request, @RequestBody EditChatNickName param){
        return chatService.editChatUserNickName(request,param);
    }

    /**
     * 发送给对方消息
     * @param param 参数
     * @return ResponseWrapper
     */
    @PostMapping("/sendMessageToChatObject")
    public ResponseWrapper sendMessageToChatObject(HttpServletRequest request, @RequestBody SendMessageParam param){
        return chatService.sendMessageToChatObject(request,param);
    }

}
